package com.ssm.service.impl;

import com.ssm.pojo.Classes;
import com.ssm.service.ClassesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ssm.dao.ClassesDao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("classesService")
public class ClassesServiceImpl implements ClassesService {

    @Autowired
    private ClassesDao classesDao;

    @Override
    public Map<String, Object> query(Classes classes) throws Exception {
        Map<String, Object> classesMap=new HashMap<>();
        List list=classesDao.queryClass(classes);
        classesMap.put("data",list);
        classesMap.put("code","200");
        classesMap.put("massage","success");
        return classesMap;
    }

    @Override
    public Map<String, Object> insert(Classes classes) throws Exception {
        Map<String, Object> classesMap=new HashMap<>();
        int i =classesDao.addClasses(classes);
        if(i>0){
            classesMap.put("data",i);
            classesMap.put("code","200");
            classesMap.put("massage","success");
        }else{
            classesMap.put("data",i);
            classesMap.put("code","000");
            classesMap.put("massage","fail");
        }
        return classesMap;
    }


}
